package com.cinema.util;

import cn.hutool.captcha.CircleCaptcha;
import cn.hutool.captcha.LineCaptcha;
import com.cinema.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.UUID;

@Component
public class CaptchaUtil {
    private static LineCaptcha lineCaptcha = cn.hutool.captcha.CaptchaUtil.createLineCaptcha(200, 100,4,100);
    @Autowired
    RedisService redisService;
    public  String[] getImage() {
        lineCaptcha.createCode();
        String code=lineCaptcha.getCode();
        String key= UUID.randomUUID().toString();
        redisService.setex(key,300,code);
        //存储验证
        String imgBase=lineCaptcha.getImageBase64();
        String[] result={key,imgBase};
        return result;


    }
    public  void main(String[] args){
        System.out.println(getImage());
    }

}
























